<include file="Public/header" />
<title>编辑价格</title>
</head>
<body>
<div class="pd-20">
<form action="__URL__/add_goods" name="postForm" id="postForm" method="post" >
	<table class="table table-border table-bordered table-bg">
			<thead>
			<tr>
				<th>商品名称</th>
				<th>商品料号</th>
				<th>商品数量</th>
				<th>商品价格</th>
			</tr>
			</thead>
		<volist name="detail" id="vo">
		<tbody>
			<tr class="text-c">
				<input type="hidden" type="checkbox" class="ids" checked="checked"  name="order_goods_id" value="<{$vo.id}>" >
				<td width="35%" class="text-l" style="background-color:#f5f5f5">
					<{$vo.goods_name}>
				</td>
				<td class="text-l" width="25%">
					<{$vo.bar_code}>
				</td>
				<td width="15%" class="text-r" style="background-color:#f5f5f5">
					<{$vo.goods_nums}>
				</td>
				<td class="text-l">
					<input type="text" name="buyer_price" class="input-text" value="<{$vo.goods_price}>" >
				</td>
			</tr>
		</tbody>
		</volist>
	</table>
	<input type="button" class="btn btn-primary radius mt" onclick="confirm_edit_price()" value="更新">
</form>
</div>
<script type="text/javascript" src="__PUBLIC__/js/jquery.form.js"></script>
<script>
	function confirm_edit_price(){
        var error=0;
        var post_json={
            'id':<{:I('id')}>,
            'data':{}
        };
        $("table tbody tr").each(function (){
            if($(this).find("input:eq(1)").val()<=0 || isNaN($(this).find("input:eq(1)").val()) ){
                error=1;
                layer.msg('价格必须是大于0的数字',{icon:0,offset:['160px'],shade:0.1});
            }
            post_json.data[$(this).index()]=$(this).find("input:eq(0)").val()+':'+$(this).find("input:eq(1)").val();
        });

        if(error==1){
            return false;
        }
			$.ajax({
				type: 'POST',
				data: post_json,
				url: "<{:U('confirm_edit_price')}>",
				success:function(data){
					if(data.status==1){	
						layer.msg(data.message,function(){
							parent.window.location.href =parent.window.location.href;
						});
					}else{
						layer.msg(data.message);
					}
					return false;
				}
			})
	}

</script>
</body>
</html>